package com.sunshine.lnuplus.view.CountDown;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProviders;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.sunshine.lnuplus.R;
import com.sunshine.lnuplus.view.Main.MainActivity;

public class CountDownFragment extends Fragment {

    private CountDownViewModel mViewModel;

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        mViewModel = ViewModelProviders.of(this).get(CountDownViewModel.class);

        return inflater.inflate(R.layout.fragment_count_down, container, false);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mViewModel = ViewModelProviders.of(this).get(CountDownViewModel.class);

        MainActivity activity = (MainActivity) getActivity();
        activity.getSupportActionBar().setSubtitle(null);
        RecyclerView recyclerView = getView().findViewById(R.id.count_down_recycler);
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        CountDownRecyclerHelper recyclerHelper = new CountDownRecyclerHelper(getActivity(),getFragmentManager());
        recyclerView.setAdapter(recyclerHelper);
        recyclerHelper.setLists(mViewModel.getLesson());
    }

}